package com.zy.thread.bank3.jiaoti;

/**
 * @Author Gong
 * @Description
 * @dATE 2021/12/14 15:10
 **/
public class Communication implements Runnable {
    int i = 1;

    @Override
    public void run() {
        while (true) {
            synchronized (this) {
                notify();
                if (i <= 100) {
                    System.out.println(Thread.currentThread().getName() + ":"
                            + i++);
                } else {
                    break;
                }
                try {
                    wait();
                } catch (InterruptedException e) {
                }
            }
        }
    }
}
